from litemall.web_ui.frame.pages.base_page import BasePage
from selenium.webdriver.common.by import By



class ListPage(BasePage):

    def click_add(self):
        # 点击【添加】按钮
        self.do_click(By.XPATH, "//*[text()='添加']")

        from litemall.web_ui.frame.pages.mall_manage.create_page import CreatePage
        return CreatePage(self.driver)

    def get_add_result(self):
        # 获取添加商品类目的结果
        add_result = self.wait_element_visible(By.XPATH, "//*[text()='创建成功']")

        return add_result

    def click_delete(self, name):
        # 点击删除对应商品类目
        self.do_click(By.XPATH, f"//*[text()='{name}']/../..//*[text()='删除']")

        return self

    def get_del_result(self):
        # 获取删除商品类目的结果
        del_result = self.wait_element_visible(By.XPATH, "//*[text()='删除成功']")

        return del_result
